import { ajax } from './ajax.js';

let txtEcho = document.getElementById('txtEcho');
let btnEcho = document.getElementById('btnEcho');
let divEchoo = document.getElementById('divEcho');

btnEcho.addEventListener('click', () => {
  ajax.send('/', { echo: txtEcho.value }, 'GET', (data) => {
    console.log('应答结果：', data);
    divEchoo.innerHTML = data.message;
  });
});

//拼音的部分
let txtWKL = document.getElementById('txtWKL');
let btnWKL = document.getElementById('btnWKL');
let divWKL = document.getElementById('divWKL');

btnWKL.addEventListener('click', () => {
  ajax.send('/api/pinyin', { info: txtWKL.value }, 'POST', (data) => {
    divWKL.innerHTML = data.message;
  });
});
